/*
 * Panel.java
 *
 * Created on March 22, 2007, 4:51 PM
 */

package gui;

import javax.swing.JOptionPane;
import pedidospanel.ConnectionBean;
import pedidospanel.FilesHelper;
import pedidospanel.HttpHelper;

/**
 *
 * @author  Alirio
 */
public class Panel extends javax.swing.JFrame {
  
  /** Creates new form Panel */
  public Panel() {
    initComponents();
  }
  
  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
  private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jButton4 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jButton6 = new javax.swing.JButton();
    jButton7 = new javax.swing.JButton();
    jButton8 = new javax.swing.JButton();
    jButton9 = new javax.swing.JButton();
    jButton10 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Panel de Control (Web Pedidos)");
    addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosed(java.awt.event.WindowEvent evt) {
        formWindowClosed(evt);
      }
    });

    jButton1.setText("Subir Clientes (files > web)");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton1ActionPerformed(evt);
      }
    });

    jButton2.setText("Subir Productos (files > web)");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton2ActionPerformed(evt);
      }
    });

    jButton3.setText("Subir Vendedores (files > web)");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton3ActionPerformed(evt);
      }
    });

    jButton4.setText("Descargar Ordenes (web > files)");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton4ActionPerformed(evt);
      }
    });

    jButton5.setText("Subir CxC (files > web)");
    jButton5.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton5ActionPerformed(evt);
      }
    });

    jButton6.setText("Subir Cheques (files > web)");
    jButton6.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton6ActionPerformed(evt);
      }
    });

    jButton7.setText("Subir Plan (files > web)");
    jButton7.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton7ActionPerformed(evt);
      }
    });

    jButton8.setText("Mantenimiento Vendedores");
    jButton8.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton8ActionPerformed(evt);
      }
    });

    jButton9.setText("Depurar Pedidos (historico)");
    jButton9.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton9ActionPerformed(evt);
      }
    });

    jButton10.setText("Subir Status Pedidos (files > web)");
    jButton10.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton10ActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
          .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addGap(41, 41, 41)
        .addComponent(jButton1)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jButton2)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jButton3)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jButton5)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jButton6)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jButton7)
        .addGap(4, 4, 4)
        .addComponent(jButton10)
        .addGap(16, 16, 16)
        .addComponent(jButton4)
        .addGap(22, 22, 22)
        .addComponent(jButton8)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jButton9)
        .addContainerGap())
    );
    pack();
  }// </editor-fold>//GEN-END:initComponents

  private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
    FilesHelper.readOrderStatus();
    JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Status de Pedidos", JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton10ActionPerformed
  
  private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
    FilesHelper.debug();
    JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Plan", JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton9ActionPerformed
  
  private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
    //HttpHelper.callHttpPage();
    java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
        SalesmanUI smui = new SalesmanUI();
        smui.setCnn(ConnectionBean.getConnection());
        smui.setVisible(true);
      }
    });
  }//GEN-LAST:event_jButton8ActionPerformed
  
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
      FilesHelper.readPlan();
      JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Plan", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jButton7ActionPerformed
    
  private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
    FilesHelper.readCheques();
    JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Cheques", JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton6ActionPerformed
  
  private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    FilesHelper.readEdoCtaFile();
    JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Ctas x Cobrar", JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton5ActionPerformed
  
  private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    FilesHelper.writeOrderFiles();
    JOptionPane.showMessageDialog(this, "Proceso completado!","Descargar Ordenes", JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton4ActionPerformed
  
  private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
    FilesHelper.readSalesmenFile();
    JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Archivo de Vendedores", JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton3ActionPerformed
  
  private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
    FilesHelper.readProductsFile();
    JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Archivo de Productos", JOptionPane.INFORMATION_MESSAGE);
  }//GEN-LAST:event_jButton2ActionPerformed
  
  private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
// TODO add your handling code here:
    ConnectionBean.close();
  }//GEN-LAST:event_formWindowClosed
  
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
      FilesHelper.readCustomersFile();
      JOptionPane.showMessageDialog(this, "Proceso completado!","Subir Archivo de Clientes", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jButton1ActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
          new Panel().setVisible(true);
        }
      });
    }
    
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton jButton1;
  private javax.swing.JButton jButton10;
  private javax.swing.JButton jButton2;
  private javax.swing.JButton jButton3;
  private javax.swing.JButton jButton4;
  private javax.swing.JButton jButton5;
  private javax.swing.JButton jButton6;
  private javax.swing.JButton jButton7;
  private javax.swing.JButton jButton8;
  private javax.swing.JButton jButton9;
  // End of variables declaration//GEN-END:variables
  
}
